function tracespect()
%
% tracespect - compute the spectrum on a set of traces.
%

global VOLTAGE DFILE

[fsl, first_isi, nr_spikes, spike_train]=find_spikes2(DFILE, VOLTAGE, 0, 10000, -20);

s_v = size(VOLTAGE);

t1 = [1:10];
t2 = [floor(s_v(1)/2):s_v(1)]; % traces for spectal comparison.

nt1 = length(t1);
nt2 = length(t2);
h = spectrum.mtm(3/2, 'adapt'); % use periodogram format.
for i = 1:nt1; hctl(i)=psd(h, detrend(VOLTAGE(t1(i),:)), 'Fs', 50000); end;
% get average of spectrum from these traces.
sctlave = zeros(size(hctl(1).Data));
for i = 1:nt1
    sctlave = sctlave + hctl(i).Data;
end;
sctlave = sctlave/nt1;
t2

j = 0;
for i = 1:nt2
    if(nr_spikes(t2(i)) == 0) 
        j = j + 1;
        t2(i)
        htest(j)=psd(h, detrend(VOLTAGE(t2(i),:)), 'Fs', 50000);
    end;
end;
% get average of spectrum from these traces.
stestave = zeros(size(htest(1).Data));
if(j > 0)
    for i = 1:j
    stestave = stestave + htest(i).Data;
end;
stestave = stestave/j;
    
end;

hf = findobj('tag', 'tracespect');
if(isempty(hf) || hf == 0)
    hf = figure('tag', 'tracespect');
end;
figure(hf);
loglog(hctl(1).Frequencies, sctlave, 'g-');
hold on;
loglog(htest(1).Frequencies, stestave, 'r-');
set(gca, 'Xlim', [1 100]);

